<?php

class Options extends CActiveRecord {
    /**
     * The followings are the available columns in table 'options':
     * @var integer $options_id
     * @var string $options_name
     * @var string $options_value
     * @var string $options_import_file
     * @var integer $options_type
     * @var integer $options_autoload
     */

    public function __get($name) {
        $value = parent::__get($name);
        if($name === 'options_value') {
            $value = unserialize(stripslashes($value));
        }
        return $value;
    }

    public static $TYPES = array('Global', 'Component', 'Module', 'Params');

    /**
     * Returns the static model of the specified AR class.
     * @return CActiveRecord the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'options';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        return array(
                array('options_name','length','max'=>255),
                array('options_name, options_value, options_type, options_autoload', 'required'),
                array('options_type, options_autoload', 'numerical', 'integerOnly'=>true),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
                'options_id' => Yii::t('crm', 'ID'),
                'options_name' => Yii::t('crm', 'Name'),
                'options_value' => Yii::t('crm', 'Inhalt'),
                'options_type' => Yii::t('crm', 'Typ'),
                'options_autoload' => Yii::t('crm', 'Autoloading'),
        );
    }
}